﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using VCDIFF.Tools;
namespace VCDIFF.Tests
{
    
    
    /// <summary>
    ///This is a test class for VCDIFFToolsTest and is intended
    ///to contain all VCDIFFToolsTest Unit Tests
    ///</summary>
    [TestClass()]
    public class VCDIFFToolsTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GetRange(byte[] data, UInt64 beginning)
        ///</summary>
        [TestMethod()]
        public void GetRangeTest1()
        {
            byte[] data = new byte[9] { 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D };
            ulong beginning = 3;
            byte[] expected = new byte[6] { 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D };
            byte[] actual = VCDIFFTools.GetRange(data, beginning);
            bool same = true;

            if (expected.Length != actual.Length)
                same = false;
            else
                for (int i = 0; i < expected.Length; i++)
                    if (expected[i] != actual[i])
                        same = false;

            Assert.AreEqual(true, same);
        }

        /// <summary>
        ///A test for GetRange(byte[] data, UInt64 beginning, UInt64 end)
        ///</summary>
        [TestMethod()]
        public void GetRangeTest()
        {
            byte[] data = new byte[9] { 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D };
            ulong beginning = 3;
            ulong end = 6;
            byte[] expected = new byte[4] { 0x68, 0x69, 0x6A, 0x6B };
            byte[] actual = VCDIFFTools.GetRange(data, beginning, end);
            bool same = true;

            if (expected.Length != actual.Length)
                same = false;
            else
                for (int i = 0; i < expected.Length; i++)
                    if (expected[i] != actual[i])
                        same = false;

            Assert.AreEqual(true, same);                        
        }

        /// <summary>
        ///A test for VCDIFFTools Constructor
        ///</summary>
        [TestMethod()]
        public void VCDIFFToolsConstructorTest()
        {
            VCDIFFTools target = new VCDIFFTools();
        }
    }
}
